// ========== MALL - 营销模块 ==========

import dayjs from "dayjs";

/**
 * 优惠类型枚举
 */
export const PromotionDiscountTypeEnum = {
    PRICE: {
        type: 1,
        name: '满减'
    },
    PERCENT: {
        type: 2,
        name: '折扣'
    }
}

/**
 * 优惠劵模板的有限期类型的枚举
 */
export const CouponTemplateValidityTypeEnum = {
    DATE: {
        type: 1,
        name: '固定日期可用'
    },
    TERM: {
        type: 2,
        name: '领取之后可用'
    }
}

/**
 * 营销的商品范围枚举
 */
export const PromotionProductScopeEnum = {
    ALL: {
        scope: 1,
        name: '通用劵'
    },
    SPU: {
        scope: 2,
        name: '商品劵'
    },
    CATEGORY: {
        scope: 3,
        name: '品类劵'
    }
}


// 时间段的状态枚举
export const TimeStatusEnum = {
    WAIT_START: '即将开始',
    STARTED: '进行中',
    END: '已结束',
}

export const getTimeStatusEnum = (startTime, endTime) => {
    const now = dayjs();
    if (now.isBefore(startTime)) {
        return TimeStatusEnum.WAIT_START;
    } else if (now.isAfter(endTime)) {
        return TimeStatusEnum.END;
    } else {
        return TimeStatusEnum.STARTED;
    }
}

export const paymentMethodsEnum = {
    "wx_pub": "微信 JSAPI 支付",
    "wx_lite": "微信小程序支付",
    "wx_app": "微信 App 支付",
    "wx_native": "微信 Native 支付",
    "wx_wap": "微信 Wap 网站支付",
    "wx_bar": "微信付款码支付",
    "alipay_pc": "支付宝 PC 网站支付",
    "alipay_wap": "支付宝 Wap 网站支付",
    "alipay_app": "支付宝App 支付",
    "alipay_qr": "支付宝扫码支付",
    "alipay_bar": "支付宝条码支付",
    "mock": "模拟支付",
    "wallet": "钱包支付"
};
/**
 * 支付方法枚举
 * @param key 键值
 * @returns {string|*}
 */
export const getPaymentMethodsEnum = (key)=>{
    if(paymentMethodsEnum[key]){
        return paymentMethodsEnum[key];
    }
    return "";
}

export const payStatusEnum  = {
    true:"已经支付过",
    false:"没有支付过"
}
/**
 * 是否支付过
 * @param key
 * @returns {string|*}
 */
export const getPayStatusEnum = (key)=>{
    if(payStatusEnum[key]){
        return payStatusEnum[key];
    }
    return "";
}

export const printStatusEnum = {
    0:"待打印",
    1:"打印中",
    2:"已打印",
    3:"打印失败"
}
/**
 * 打印状态
 * @param key
 * @returns {string|*}
 */
export const getPrintStatusEnum = (key)=>{
    if(printStatusEnum[key]){
        return printStatusEnum[key];
    }
    return "";

}




